﻿//处理radio
function ControlRadio(objArr) {
    //获取选中项的value
    this.GetSelectedVal = function () {
        var value = "";
        if (this.IsSelected()) {
            for (var i = 0; i < objArr.length; i++) {
                if ($(objArr[i]).attr("checked") == "checked") {
                    value = $(objArr[i]).val();
                }
            }
        }
        return value;
    }

    //根据value选中一项
    this.SetSelectedByValue = function (value) {
        for (var i = 0; i < objArr.length; i++) {
            if ($(objArr[i]).val() == value) {
                $(objArr[i]).attr("checked", "checked");
            }
        }
    }

    //判断是否选中最少一项
    this.IsSelected = function () {
        var num = 0;
        for (var i = 0; i < objArr.length; i++) {
            if ($(objArr[i]).attr("checked") == "checked") {
                num++;
            }
        }
        if (num == 0) {
            alert("最少选择一项!");
            return false;
        }
        else {
            return true;
        }
    }
}